package dd.view;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import dd.control.closeChoiceConfirmButtonController;
import dd.model.Event;

public class ModeratorAddChoices extends JFrame {

	private static final JLabel JLabel = null;
	private JPanel contentPane;
	private JTextField choice1TextField;
	
	Event event;
	JLabel[] choicesLabel;
	JTextField[] choicesTextField;
	private JLabel lblPleaseAddYour;
	/**
	 * Launch the application.
	 */
	
	/**
	 * Create the frame.
	 */
	public ModeratorAddChoices(Event event) {
		this.event = event;
		setTitle("Closed mode: Moderator add choices");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 541, 350);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		choicesLabel = new JLabel[this.event.getNumberLines()];
		choicesTextField = new JTextField[this.event.getNumberLines()];
		for(int i = 0; i < this.event.getNumberLines(); i++) {
			choicesLabel[i] = new JLabel("Choice " + (i+1) + "");
			choicesLabel[i].setBounds(139, 85 + i*40, 56, 20);
			contentPane.add(choicesLabel[i]);
			choicesTextField[i] = new JTextField();
			choicesTextField[i].setBounds(209, 85 + i*40, 100, 20);
			contentPane.add(choicesTextField[i]);
		}
		
		JButton confirmButton = new JButton("Confirm");
		confirmButton.setBounds(190, 85 + event.getNumberLines()*40, 89, 23);
		contentPane.add(confirmButton);
		confirmButton.addActionListener(new closeChoiceConfirmButtonController(this, event));
		
		lblPleaseAddYour = new JLabel("Please add your choices in the closed mode");
		lblPleaseAddYour.setHorizontalAlignment(SwingConstants.CENTER);
		lblPleaseAddYour.setBounds(85, 32, 339, 14);
		contentPane.add(lblPleaseAddYour);
	}
	
	public JTextField getTextField(int i) {
		return choicesTextField[i];
	}
}
